﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SiGeSIB.Data.Common
{
	public class DbException : Exception
	{
		public DbException()
			: base() { }
		public DbException(string message)
			: base(message) { }
	}

	public class ValidationError : Exception
	{
		public ValidationError(object invalidControl, string message)
			: base(message)
		{
			InvalidControl = invalidControl;
		}
		public ValidationError(string fieldName, string message)
			: base(message)
		{
			FieldName = fieldName;
		}

		public string FieldName { get; private set; }
		public object InvalidControl { get; private set; }
	}

	public class InvalidPasswordException : ValidationError
	{
		public InvalidPasswordException(string fieldName, string message)
			: base(fieldName, message) { }
	}
	public class InvalidLoginException : ValidationError
	{
		public InvalidLoginException(string fieldName, string message)
			: base(fieldName, message) { }
	}

	public class ExceptionsContainer : Exception, IEnumerable<Exception>
	{
		private List<Exception> _InnerExceptions;

		public ExceptionsContainer()
			: base()
		{
			_InnerExceptions = new List<Exception>();
		}

		public void Add(Exception e)
		{
			_InnerExceptions.Add(e);
		}

		#region IEnumerable<Exception> Members

		public IEnumerator<Exception> GetEnumerator()
		{
			return _InnerExceptions.GetEnumerator();
		}

		#endregion

		#region IEnumerable Members

		System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
		{
			return _InnerExceptions.GetEnumerator();
		}

		#endregion
	}
}
